package com.matchmealpha;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Adapter;
import android.widget.BaseAdapter;

public class FindFriendsListAdapter extends BaseAdapter  {
	private Context context;
	private List<String> friendsList;
	private int selectedPosition;
	private String sessionid;
	
	public FindFriendsListAdapter(Context context, List<String> friendsList, String sessionid) {
		this.context = context;
		this.friendsList = friendsList;
		this.selectedPosition = Adapter.NO_SELECTION;
		this.sessionid = sessionid;
	}
	
	public int getSelectedPosition(){
		return this.selectedPosition;
	}
	@Override
	public int getCount() {
		return this.friendsList.size();
	}

	@Override
	public Object getItem(int position) {
		return this.friendsList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
		//return  this.friendsList.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if ( convertView != null ){
			((FindFriendsView)convertView).setString(this.friendsList.get(position));
		}
		else {
			convertView = new FindFriendsView(this.context,friendsList.get(position), sessionid);
		}
		return convertView;
	}
	
}
